home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mgr / sparcmgr / demo3.zoo / demo / misc / stringart.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-01-24  |  2.7 KB  |  107 lines

  1. /*                        Copyright (c) 1987 Bellcore
  2.  *                            All Rights Reserved
  3.  *       Permission is granted to copy or use this program, EXCEPT that it
  4.  *       may not be sold for profit, the copyright notice must be reproduced
  5.  *       on copies, and credit should be given to Bellcore where it is due.
  6.  *       BELLCORE MAKES NO WARRANTY AND ACCEPTS NO LIABILITY FOR THIS PROGRAM.
  7.  */
  8. /*    $Header: stringart.c,v 4.3 88/06/30 11:41:47 sau Exp $
  9.     $Source: /tmp/mgrsrc/demo/misc/RCS/stringart.c,v $
  10. */
  11. static char    RCSid_[] = "$Source: /tmp/mgrsrc/demo/misc/RCS/stringart.c,v $$Revision: 4.3 $";
  12.  
  13. /*    stringart.c    13    84/04/22    */
  14.  
  15. #include <stdio.h>
  16. #include <sys/time.h>
  17. #include "term.h"
  18. #include "restart.h"
  19.  
  20. #define NUMLINES    343        /* number of vectors in a design */
  21. #define NUMFUNCTIONS    13        /* number of functions */
  22. #define RAWMIN        (-10000)    /* smallest raw data value */
  23. #define RAWMAX        (10000)        /* largest raw data value */
  24.  
  25. extern int function[NUMFUNCTIONS][NUMLINES];
  26.  
  27. #define fsleep(x) \
  28.    { \
  29.    struct timeval time; \
  30.    time.tv_sec = 0; \
  31.    time.tv_usec = x; \
  32.    select(0,0,0,0,&time); \
  33.    }
  34.  
  35. main(argc,argv)
  36.     int argc;
  37.     char *argv[];
  38. {
  39.     register int m,i,j,k,l;
  40.     int xoffset;
  41.     int yoffset;
  42.     int xscale, yscale, rscale;
  43.     int xmin,xmax,ymin,ymax;
  44.     short lines[4][NUMLINES];
  45.     int lcolor,bcolor;    /* line colors */
  46.         int slp=0;
  47.  
  48.     ckmgrterm( *argv );
  49.  
  50.     if (argc>1 && strcmp(argv[1],"-s")==0) {
  51.            argc--; argv++;
  52.            slp++;
  53.            }
  54.     rscale = (RAWMAX-RAWMIN);
  55.     if (argc >= 5) {
  56.         xmin = atoi(argv[1]);
  57.         ymin = atoi(argv[2]);
  58.         xmax = atoi(argv[3]);
  59.         ymax = atoi(argv[4]);
  60.         }
  61.     else {
  62.         xmin = 0;
  63.         ymin = 0;
  64.         xmax = 999;
  65.         ymax = 999;
  66.         }
  67.  
  68.     xscale = xmax-xmin;
  69.     yscale = ymax-ymin;
  70.     xoffset = xmin;
  71.     yoffset = ymin;
  72.  
  73.     srand(getpid());
  74.     m_setup(0);
  75.     m_func(B_SET);
  76.  
  77.     Restart();
  78.     m_clear(); m_flush();
  79.     while(1) {
  80.         i=(rand()>>5)%NUMFUNCTIONS;
  81.         while((j=(rand()>>5)%NUMFUNCTIONS)==i);
  82.         k=(rand()>>5)%NUMFUNCTIONS;
  83.         while((l=(rand()>>5)%NUMFUNCTIONS)==k);
  84.         bcolor = rand()%24;
  85.         m_bcolor(bcolor);
  86.         for(m=0;m<NUMLINES;m++) {
  87.             lines[0][m] = (function[i][m]-RAWMIN)*xscale/rscale+xoffset;
  88.             lines[1][m] = (function[k][m]-RAWMIN)*yscale/rscale+yoffset;
  89.             lines[2][m] = (function[j][m]-RAWMIN)*xscale/rscale+xoffset;
  90.             lines[3][m] = (function[l][m]-RAWMIN)*yscale/rscale+yoffset;
  91.             }
  92.         m_clear();
  93.         for(m=0;m<NUMLINES;m++) {
  94.             while((lcolor = rand()%24) == bcolor);
  95.             m_linecolor(B_SRC,lcolor);
  96.             m_line(lines[0][m],lines[1][m],
  97.                       lines[2][m],lines[3][m]);
  98.                    if (slp) {
  99.                       m_flush();
  100.                       fsleep(60000);
  101.                       }
  102.                    }
  103.     m_flush();
  104.     sleep(argc>5?atoi(argv[5]):3);
  105.     }
  106. }
  107.